<?php

namespace app\api\controller;

use app\api\model\ShopComment;
use think\Controller;

class Comment extends Base
{
    protected $beforeActionList = [
        'checkToken' => ['only' => 'save']
    ];
    //提交评价
    public function save()
    {
        $data = input('post.');
        $result = $this->validate($data,'Comments');
        if(true !== $result){
            return self::apiResp(['msg'=>$result],401);
        }
        $orderNo = input('post.order_no');
        $comments = input('post.comments/a');

        $res = (new ShopComment())->saveComments($orderNo, $this->userId, $comments);
        return self::apiResp($res);
    }

    //更多评价
    public function list()
    {
        $page = input('page',1);
        $row = input('row',10);
        $proId = input('pro_id');
        $res = ShopComment::getList($proId,$page,$row);
        return self::apiResp($res);
    }
}
